<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var getRow = function(rowIndex) {
    if(rowIndex == 0){
        return [1]
    }
    else if(rowIndex == 1){
        return [1,1]
    }
    var arr = [[1],[1,1]]
    var temp
    for( var i = 2 ; i<rowIndex+1 ; i++ ){
        var xxx = [1,1]
        for( var k = 1 ; xxx.length<i+1 ; k++ ){
            temp = arr[i-1][k-1] + arr[i-1][k]
            xxx.splice(k,0,temp)
        }
        arr.push(xxx)
    }
    return arr[rowIndex]
};
var rowIndex = 3
console.log(getRow(rowIndex))
    </script>
</body>
</html>